package org.dromara.solonplugins.job.impl;

import org.dromara.solonplugins.job.IJobCallback;
import org.dromara.solonplugins.job.JobInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 默认的Job回调实现
 *
 * @author: aoshiguchen
 */
public class DefaultJobCallback implements IJobCallback {
    private static final Logger log = LoggerFactory.getLogger(DefaultJobCallback.class);

    /**
     * 执行日志
     * @param jobInfo Job信息
     * @param param 执行时的Job参数
     * @param throwable 执行Job产生的异常
     */
    @Override
    public void executeLog(JobInfo jobInfo, String param, Throwable throwable) {
        if (null == throwable) {
            log.debug("[Solon Plugin Job] Job执行 id:{} name:{} desc:{} param:{}", jobInfo.getId(), jobInfo.getName(), jobInfo.getDesc(), param);
        } else {
            log.error("[Solon Plugin Job] Job执行 id:{} name:{} desc:{} param:{}", jobInfo.getId(), jobInfo.getName(), jobInfo.getDesc(), param, throwable);
        }
    }

}
